package com.wei.frame.ui.activity;

import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.gyf.immersionbar.BarHide;
import com.gyf.immersionbar.ImmersionBar;
import com.wei.frame.R;
import com.wei.frame.di.component.AppComponent;
import com.wei.frame.ui.imageloader.GlideApp;
import com.wei.frame.utils.RxUtils;

import java.util.concurrent.TimeUnit;

import butterknife.BindView;
import io.reactivex.Observable;

/**
 * 作者：赵若位
 * 时间：2020/8/20 11:24
 * 邮箱：1070138445@qq.com
 * 功能：
 */
public class SplashActivity extends BaseActivity
{
    @BindView(R.id.iv_advert)
    ImageView mIvAdvert;

    @Override
    public int getLayoutId()
    {
        return R.layout.activity_splash;
    }

    @Override
    protected void setStatusColor()
    {
        ImmersionBar.with(this)
                .hideBar(BarHide.FLAG_HIDE_BAR)
                .init();
    }

    @Override
    public void bindComponent(@Nullable AppComponent component)
    {
    }

    @Override
    public void initView()
    {
        GlideApp.with(this)
                .load("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1601373415036&di=8c8bd9e3cbb65ab95421fbe5b72e7879&imgtype=0&src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F201710%2F13%2F20171013191329_XN3Sk.thumb.400_0.jpeg")
                .into(mIvAdvert);
    }

    @Override
    public void initData()
    {
    }

    private void delay(@Nullable long time)
    {
        Observable.timer(time, TimeUnit.MILLISECONDS)
                .compose(RxUtils.applySchedulers())
                .doFinally(() ->
                {
                    openActivity(MainActivity.class);
                    finish();
                }).compose(RxUtils.applyLifecycle(this))
                .subscribe();
    }
}
